<template>
	<view class="inquirySelect-wrap">
		<view class="section1">
			<image src="http://k8s.vendingtech.vip/images/ikon@2x.png" class="pic1"></image>
			<view class="layer1" v-if="questionOrderForm.type != 0">
				<text lines="1" class="info1">20s</text>
				<text lines="1" class="word1">快速匹配专业医生</text>
			</view>
			<view class="layer2" @click="selectInquiryType(0)">
				<view class="section2">
					<image src="http://k8s.vendingtech.vip/images/image_text@2x.png" class="pic2"></image>
					<view class="outer1">
						<text lines="1" decode="true" class="word2">图文问诊&nbsp;&nbsp;{{price0}}元 / 次</text>
						<text lines="1" class="txt1">和医生一对一在线图片文字交流病情</text>
					</view>
					<image src="http://k8s.vendingtech.vip/images/next_icon@2x.png" class="icon1"></image>
				</view>
			</view>
			<view class="layer2" @click="selectInquiryType(1)">
				<view class="section2">
					<image src="http://k8s.vendingtech.vip/images/video_icon@2x.png" class="pic2"></image>
					<view class="outer1">
						<text lines="1" decode="true" class="word2">视频问诊&nbsp;&nbsp;{{price1}}元 / 次</text>
						<text lines="1" class="txt1">和医生一对一在线视频沟通病情</text>
					</view>
					<image src="http://k8s.vendingtech.vip/images/next_icon@2x.png" class="icon1"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
	data() {
		return {
			price0:"0.00",
			price1:"0.00"
		};
	},
	computed: {
		...mapState({
			questionOrderForm: state => state.questionOrderForm
		})
	},
	onLoad(option) {
		//  商品id (0：极速图文问诊 1：极速视频问诊 2：开药图文问诊 3：开药视频问诊 )
		this.questionOrderForm.type = option.type ? option.type : 0; //0专家  1极速  2开药
		this.questionOrderForm.doctorId = option.doctorId ? option.doctorId  : null;
		this.setQuestionOrderForm(this.questionOrderForm);
	},
	onShow() {
		if(this.questionOrderForm.type!=0){
			this.queryCommodityList()
		}else{
			this.queryDoctorDetail()
		}

	},
	methods: {
		...mapMutations({
			setQuestionOrderForm: 'setQuestionOrderForm',
			clearQuestionOrderForm: 'clearQuestionOrderForm'
		}),

		//选择问诊类型并跳转
		selectInquiryType(type) {
			
			this.questionOrderForm.price = this[`price${type}`]
			this.questionOrderForm.inquiryType = type
			this.setQuestionOrderForm(this.questionOrderForm);
			if (this.questionOrderForm.type != 2) {
				
				this.gotoRouter("/pages-inquiry/inquiryDescribe/inquiryDescribe");
			} else {
				this.gotoRouter("/pages-inquiry/drugDescribe/drugDescribe");
			}
		},
		
		
		//医生详情
		queryDoctorDetail() {
			this.$api
				.queryDoctorDetail({
					params: {
						id: this.questionOrderForm.doctorId
					}
				})
				.then(res => {
					if (res.code == 200) {
						this.price0 =res.result.amount,
						this.price1 =res.result.videoAmount
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					}
				});
		},
		
		

		//商品列表
		queryCommodityList() {
			this.$api
				.queryCommodityList({
					params:{
						category: this.questionOrderForm.type==1 ? '0,1' : '2,3',
					}
				})
				.then(res => {
					if (res.code == 200) {
						if(this.questionOrderForm.type==1){
							this.price0 =res.result.records[0].price
							this.price1 =res.result.records[1].price
						}else{
							this.price0 =res.result.records[2].price
							this.price1 =res.result.records[3].price
						}
				
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					}
				});
		}


	}
};
</script>

<style lang="less">
@import './inquirySelect.less';
</style>
